package com.lc.qianrenshiye.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

/**
 * Created by Administrator on 2016/11/28.
 */
@HttpInlet(Conn.LOGIN_SEL)
public class LoginPost extends BaseAsyPost<LoginPost.UserInfo> {

    public String username, password;

    public LoginPost(AsyCallBack<UserInfo> asyCallBack) {
        super(asyCallBack);
    }


    @Override
    protected UserInfo parser(JSONObject object) throws Exception {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            UserInfo userInfo = new UserInfo();

            JSONObject infoObject = object.optJSONObject("data");

            userInfo.sid = infoObject.optString("sid");
            userInfo.uid = infoObject.optString("uid");
            userInfo.username = infoObject.optString("username");

            return userInfo;
        }

        return null;
    }

    public static class UserInfo {

        public String uid, sid, username;
    }

}
